from MovieLand import app, db
import click
from MovieLand import models


@app.cli.command()
def hello():
    """say hello """
    click.echo('hello')

@app.cli.command()
@click.option('--drop', default=True, help='create or drop')
def initdb(drop):
    """初始化数据库表 """
    if drop:
        click.confirm("这个操作会清除数据库的表 是否需要继续进行", abort=True)
        db.drop_all()
        click.echo("清除了了所有的数据表")
    db.create_all()
    click.echo('数据库表初始化成功')


@app.cli.command()
def crawler_sarula_data():
    """抓取数据"""
    from Crawler.Sakura import SarukrCrawler, sakura_config
    s = SarukrCrawler(**sakura_config)
    s.run()